package storage_define

import "time"

const LATEST_TABLE_NAME = "gvo_latest_data"

// 历史存储
type HistoryStorage interface {
	//查看指定时间之前的记录
	FindBefore(time time.Time) []ValObject
	//条件查询
	FindByCriteria() []ValObject
	//分页查询
	Paging()
	//关闭存储
	CloseStorage()
}

// 实时存储
type LatestStorage interface {
	//保存值，不通知变动
	SaveVal(val ValObject)
	//通知值变动
	NotifyVal(tagName string)
	//保存并通知值变动
	SaveAndNotify(val ValObject)
	//固定值
	FixedVal(tagName string, val interface{})
	//取消固化
	UnFixedVal(tagName string)
	//数据变化订阅
	SubscribeNotify(subNo string)
	//取消订阅
	UnSubscribeNotify(subNo string)
	// 查询值
	FindLatestVal(tagName string) (ValObject, error)
	//条件查询 todo 不使用sql ， 对其他不友好
	FindLatestBySQL(query interface{}, args ...interface{}) []ValObject
	//是否存在
	ExistsLatestVal(tagName string) bool
	//关闭存储
	CloseStorage()
}

// 仓库
type Storage interface {
	HistoryStorage
	LatestStorage
}
